﻿public class ICharacterAttr
{
    protected CharacterBaseAttr mBaseAttr;
    protected int mCurrentHp;
    protected int mLv;
    protected int mDamageDescValue;

    protected IAttrStrategy mStrategy;

    public ICharacterAttr(IAttrStrategy strategy, int lv, CharacterBaseAttr baseAttr)
    {
        mBaseAttr = baseAttr;
        mStrategy = strategy;
        mLv = lv;
        mDamageDescValue = mStrategy.GetDamageDescValue(mLv);
        mCurrentHp = baseAttr.MMaxHp + mStrategy.GetExtraHpValue(mLv);
    }

    public int CritValue => mStrategy.GetCritRateDamageValue(mBaseAttr.MCritRate);
    public int CurrentHp => mCurrentHp;

    public void TakeDamage(int damage)
    {
        damage -= mDamageDescValue;
        if (damage < 1) damage = 1;
        mCurrentHp -= damage;
    }
}